package com.woniuxy.aop;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.woniuxy.entity.Bidding;
import com.woniuxy.entity.Collect;
import com.woniuxy.entity.Sign;
import com.woniuxy.mapper.LogMapperAop;

/**
 * @auther YueYangyang
 * @date 2020/7/4 15:41
 */
@Aspect
@Component
public class BiddingAop {
	@Autowired
	LogMapperAop logMapper;
	
	//切点
//	@Pointcut()
//	 public void biddingcut() {
//		 
//	 }
	
	
	//addCollection切点的,返回通知
	 @After("execution(* com.woniuxy.mapper.BiddingMapper..addCollection(..))")
	    public void afterAspect1(JoinPoint point){	 //记录收藏操作
		 Object[] args = point.getArgs();
	
		 Collect collect=(Collect) args[0];	 
		 logMapper.addCollection(collect.getU_id(), collect.getP_id());
	    }
	 
	 
	 @After("execution(* com.woniuxy.mapper.BiddingMapper..addSigner(..))")
	    public void afterAspect2(JoinPoint point){	 //记录报名操作
		 Object[] args = point.getArgs();	 
		 Sign sign=(Sign) args[0];	 
		 logMapper.addSigner(sign.getU_id(), sign.getP_id());
	    }
	 
	 @After("execution(* com.woniuxy.mapper.BiddingMapper..addBidding(..))")
	    public void afterAspect3(JoinPoint point){	 //记录竞价拍卖操作
		 Object[] args = point.getArgs();	 
		 Bidding bidding=(Bidding) args[0];	 
		 logMapper.addBidding(bidding);
	    }
	
	
	
	
	
	
	
	
	
	
	
	
 /*   @Pointcut("execution(* com.woniuxy.service.*.*(..))")
    public void Aspect(){
        System.out.println("这是切面aop");
    }

    @Before("Aspect()")
    public void beforeAspect(){
        System.out.println("这是切面aop  前置方法");
    }

    @After("Aspect()")
    public void afterAspect(){
        System.out.println("这是切面aop  后置方法");
    }

    @AfterReturning("Aspect()")
    public void afterReturningAspect(){
        System.out.println("这是切面aop  后置方法 回调方法");
    }

    @AfterThrowing("Aspect()")
    public void afterThrowingAspect(){
        System.out.println("这是切面aop  异常处理方法");
    }*/
}
